import java.util.ArrayList;
import java.util.List;

// 组合节点：文件夹
public class Folder implements IComponent {
    private String folderName;
    private List<IComponent> children = new ArrayList<>();

    public Folder(String folderName) {
        this.folderName = folderName;
    }

    public void add(IComponent component) {
        children.add(component);
    }

    public void remove(IComponent component) {
        children.remove(component);
    }

    @Override
    public void scanForViruses() {
        //System.out.println("扫描文件夹: " + folderName);

        for (IComponent child : children) {
            child.scanForViruses(); // 递归扫描子文件和子文件夹
        }
    }
}